var base = {
	baseUrl: "/prod-api/",
}

// eslint-disable-next-line
Date.prototype.format = function (format) { // 给时间添加一个处理时间格式的函数new Date().format('yyyy-MM-dd hh');
	var date = {
		'M+': this.getMonth() + 1,
		'd+': this.getDate(),
		'h+': this.getHours(),
		'm+': this.getMinutes(),
		's+': this.getSeconds(),
		'q+': Math.floor((this.getMonth() + 3) / 3),
		'S+': this.getMilliseconds()
	}
	if (/(y+)/i.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
	}
	for (var k in date) {
		if (new RegExp('(' + k + ')').test(format)) {
			// eslint-disable-next-line
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ('00' + date[k]).substr(('' + date[k]).length))
		}
	}
	return format
}

function GetQueryString(name) { //用JS获取地址栏参数的方法
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]);
	return '';
}

function environment() {
	var u = navigator.userAgent; //环境判断
	var ua = u.toLowerCase();
	return {
		WeChatFlag: ua.match(/MicroMessenger/i) == "micromessenger",
		QQFlag: ua.match(/QQ/i) == "qq",
		isAndroid: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //安卓
		isiOS: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
	}
};

function stopBodyScroll(isFixed, that) {
	var bodyEl = document.body;
	if (isFixed) { //开启
		that._top = window.scrollY;
		bodyEl.style.position = 'fixed';
		bodyEl.style.top = -that._top + 'px';
	} else { //关闭
		bodyEl.style.position = 'relative';
		bodyEl.style.top = '';
		window.scrollTo(0, that._top); // 回到原先的top
	}
};


function copyText(text) { //复制文字（该方法无法在异步环境使用 document.execCommand不支持）
	var input = document.createElement("input");
	input.setAttribute("readonly", true); //设置只读防止ios唤起键盘
	input.value = text; //copy的文字  
	document.body.appendChild(input);
	input.select();
	input.setSelectionRange(0, input.value.length), document.execCommand('Copy');
	document.body.removeChild(input);
};



// (function() { //微信内修改alert
// 	// var ua = window.navigator.userAgent.toLowerCase();
// 	// if (ua.match(/MicroMessenger/i) == 'micromessenger') { //先判断是否为微信浏览器
// 		//重写alert方法，alert()方法重写，不能传多余参数
// 		window.alert = function(name) {
// 			var iframe = document.createElement("IFRAME");
// 			iframe.style.display = "none";
// 			iframe.setAttribute("src", 'data:text/plain');
// 			document.documentElement.appendChild(iframe);
// 			window.frames[0].window.alert(name);
// 			iframe.parentNode.removeChild(iframe);
// 		}
// 	// }
// })();



function getPageAllString() {
	var mgs = {};
	var url = window.location.href;
	var a = url.indexOf("?");
	var param = '';
	if (a > -1) {
		param = url.substr(a + 1);
		var mgsArr = param.split("&");
		mgsArr.forEach(function (val) {
			var index = val.indexOf("=");
			mgs[val.substring(0, index)] = val.substring(index + 1, val.length);
		});
	};
	return {
		mgs: mgs,
		param: param
	};
}